package Day35.test;

public class Book implements Comparable<Book>{
    private Integer bookId;//图书编号
    private String bookName;//图书名
    private Float bookPrice;//图书价格

    public Book() {
    }

    public Book(Integer bookId, String bookName, Float bookPrice) {
        this.bookId = bookId;
        this.bookName = bookName;
        this.bookPrice = bookPrice;
    }

    public Integer getBookId() {
        return bookId;
    }

    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public Float getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(Float bookPrice) {
        this.bookPrice = bookPrice;
    }


    @Override
    public String toString() {
        return "Book{" +
                "bookId=" + bookId +
                ", bookName='" + bookName + '\'' +
                ", bookPrice=" + bookPrice +
                '}';
    }

    /**
     * 返回值大于0表示，当前对象大于book对象
     * 返回值等于0表示两个对象相等
     * 返回值小于0表示当前对象小于book对象
     * @param book
     * @return
     */
    @Override
    public int compareTo(Book book) {
        return this.getBookId()-book.getBookId();
        //return this.getBookId()-book.getBookId()>0?1:this.getBookId()-book.getBookId()<0?-1:0;
    }
}
